package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class RateConvert extends AppCompatActivity {
    String TAG = "rate";
    float rate = 0f;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rate_convert);
        String title = getIntent().getStringExtra("title");
        rate = getIntent().getFloatExtra("rate",0f);

        Log.i(TAG, "onCreate: title = " + title);
        Log.i(TAG, "onCreate: rate=" + rate);
        ((TextView)findViewById(R.id.title1)).setText(title);
    }
    public void onclick(View btn) {
        EditText input = findViewById(R.id.detail1);
        String s = input.getText().toString();
        float inp = Float.parseFloat(s);
        if (s.length() == 0) {
            Toast.makeText(this, "请输入数据", Toast.LENGTH_LONG).show();
            return;
        }
        Log.i(TAG, "click:进行计算");
        float result = inp/100*rate;
        ((TextView)findViewById(R.id.title1)).setText(String.valueOf(result));
    }
}